A redeem code is also known as a promo code or a promotion code, and is generally a code used by a developer to promote an actual product or a computer program product. A redeem code generally includes a digit, a character, and the like, for example, YWERE77RMJA9. A user can obtain a computer program or various other physical products by using a redeem code. After the user redeems a redeem code for a program or another physical product, the redeem code generally becomes invalid.
According to existing manners of generating and storing a redeem code, several strings are generated by using a random algorithm, the generated strings are used as redeem codes, and all the redeem codes are completely saved in storage space, for example, in a database. Correspondingly, during verification of a redeem code, the database is searched in a manner of string comparison, so as to determine whether the redeem code exists in the database, or determine whether the redeem code has already been redeemed.
According to the existing manner of generating a redeem code, in a case in which there are a very large quantity of redeem codes, repetition may also occur in randomly generated redeem codes, and therefore, during or after generation of redeem codes, removing a repetition of a generated redeem code is further needed, resulting in low efficiency of generating a redeem code. Moreover, because all redeem codes are completely saved in a database, a large amount of storage space is occupied. If the number of digits of a redeem code are reduced simply to save storage space, it cannot be ensured that a success rate of cracking a redeem code is controllable. Further, according to an existing manner of verifying a redeem code, a database, a file, or another storage medium needs to be searched in a manner of full-text comparison, resulting in a large amount of data to be searched and low efficiency of verification.